package myky.com.doctorapp.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import myky.com.doctorapp.R;
import myky.com.doctorapp.api.Address;
import myky.com.doctorapp.entity.RecDoctorListEntity;

public class HomeExpertAdapter extends BaseMultiItemQuickAdapter<RecDoctorListEntity.DataBean.PositionsBean, BaseViewHolder> {
    public HomeExpertAdapter(@Nullable List<RecDoctorListEntity.DataBean.PositionsBean> data) {
        super(data);

        addItemType(RecDoctorListEntity.GROUPITEM, R.layout.home_group_item);
        addItemType(RecDoctorListEntity.EXPERITEM, R.layout.home_expert_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, RecDoctorListEntity.DataBean.PositionsBean item) {

        switch (helper.getItemViewType()) {
            case RecDoctorListEntity.GROUPITEM:
                ImageView groupImg = helper.getView(R.id.groupImg);
                Glide.with(mContext).load(Address.IMAGE + item.getPhoto()).error(R.drawable.header).into(groupImg);
                helper.setText(R.id.groupName, item.getName());
                helper.setText(R.id.groupPepleNumber, "共" + item.getNumber() + "人");
                break;

            case RecDoctorListEntity.EXPERITEM:
                ImageView expertImg = helper.getView(R.id.expertImg);
                Glide.with(mContext).load(Address.IMAGE + item.getPhoto()).error(R.drawable.header).into(expertImg);
                helper.setText(R.id.experName, item.getName());
                helper.setText(R.id.expertTitle, item.getAdministrationname());
                helper.setText(R.id.hospitalName, item.getHospitalname());
                helper.setText(R.id.expertDepartment,item.getDepartmentname());
                break;
        }
        helper.addOnClickListener(R.id.rootView);

    }
}
